import request from "@/utils/request";
const BASE_URL = "wblog_article";

export default {
  searchPage(page, size, searchMap) {
    return request({
      url: `${BASE_URL}/comment/search/${page}/${size}`,
      method: "post",
      data: searchMap
    });
  },
   /**
   * 发布评论
   * @param {*} aid 
   */
  publishComment(pojoComment){
    return request({
      url:`${BASE_URL}/comment/publish`,
      method:"post",
      data:{"articleid":pojoComment.articleid,"targetid":pojoComment.targetid,"content":pojoComment.content}
    })
  },
  /**
   * 根据父级id查询评论
   * @param {*} parentid
   */
  getByParentId(parentid) {
    return request({
      url: `${BASE_URL}/comment/parent/${parentid}`,
      method: "get"
    });
  },
  /**
   * 根据id查询子评论
   * @param {*} id 
   */
  findChildrensById(id){
    return request({
      url:`${BASE_URL}/comment/childrens/${id}`,
      method:'post'
    })
  },
  /**
   * 根据id查询评论
   * @param {*} parentid
   */
  getById(commentid) {
    return request({
      url: `${BASE_URL}/comment/${commentid}`,
      method: "get"
    });
  },
  /**
   * 点赞
   * @param {*} id 
   */
  thumbup(id){
    return request({
      url:`${BASE_URL}/comment/thumbup/${id}`,
      method:"put"
    })
  },
  /**
   * 禁用评论
   * @param {*} commentid
   */
  disableComment(commentid) {
    return request({
      url: `${BASE_URL}/comment/disabled/${commentid}`,
      method: "put"
    });
  },
  /**
   * 回复
   * @param {*} replyComment
   */
  reply(replyComment) {
    return request({
      url: `${BASE_URL}/comment/reply`,
      method: "post",
      data: replyComment
    });
  }
};
